package com.gp.learn.common.core.utils;

import com.baomidou.mybatisplus.annotation.TableName;
import com.gp.learn.common.core.mybaitsplus.annotation.TableAlias;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.util.ObjectUtils;

public class ReflectionUtils {

    public static String getTableName(Class cls) {
        TableName tableName = AnnotationUtils.getAnnotation(cls, TableName.class);
        if (!ObjectUtils.isEmpty(tableName)) {
            return tableName.value();
        } else {
            return null;
        }
    }

    public static String getTableAlias(Class cls) {
        TableAlias tableAlias = AnnotationUtils.getAnnotation(cls, TableAlias.class);
        if (!ObjectUtils.isEmpty(tableAlias)) {
            return tableAlias.value();
        } else {
            return null;
        }
    }
}
